export const ExceptionMap = {
  Bad_Request: {
    error: 'Bad Request',
    statusCode: 400,
  },
  Unauthorized: {
    error: 'Unauthorized',
    statusCode: 401,
  },
  Payment_Required: {
    error: 'Payment Required',
    statusCode: 402,
  },
  Forbidden: {
    error: 'Forbidden',
    statusCode: 403,
  },
  Not_Found: {
    error: 'Not Found',
    statusCode: 404,
  },
  Method_Not_Allowed: {
    error: 'Method Not Allowed',
    statusCode: 405,
  },
  Not_Acceptable: {
    error: 'Not Acceptable',
    statusCode: 406,
  },
  Proxy_Authentication_Required: {
    error: 'Proxy Authentication Required',
    statusCode: 407,
  },
  Request_Timeout: {
    error: 'Request Timeout',
    statusCode: 408,
  },
  Conflict: {
    error: 'Conflict',
    statusCode: 409,
  },
  Internal_Server_Error: {
    error: 'Internal Server Error',
    statusCode: 500,
  },
};

export const SYSTEM_MESSAGE = {
  QUERY_FAIL: '查询失败',

  UPDATE_FAIL: '更新失败',

  OPERATION_FAIL: '操作失败',

  OPERATION_SUCCESS: '操作成功',

  DELETE_FAIL: '删除失败',

  CREATE_FAIL: '创建失败',

  DATA_EXIST: '数据重复',

  NAME_NOT_EMPTY: '名称不能为空',

  DATA_NOT_EXIST: '未查询到数据,数据不存在',

  INTERNAL_EXCEPTION: `内部异常`,

  DATABASE_EXCEPTION: `数据库异常`,

  MASTER_NODE_EXIST: `主节点已经存在，不能再指定`,

  NODEINFOS_NOT_EXIST: `节点部署，未配置，不能发布`,

  PRORLEASEINFOS_NOT_EXIST: `部署发布，未配置，不能发布`,

  MASTER_CANNOT_DELETE: `主节点不能被删除`,

  NODE_NOT_EXIST: `此节点不存在与k3s集群，不能添加`,

  NODE_STATUS_ERROR: `此节点为异常，不能添加`,

  PUBLISH_ERROR: '部署发布失败',

  DEPLOYING_ERROR: '部署发布中，请稍后部署',

  MONGO_IMPORT_ERROR: 'Mongo数据库导入发布数据失败',

  IMPORT_ERROR: '正在导入中，请稍后导入',

  EXPORT_ERROR: '正在导出中，请稍后导出',

  GET_SERVICE_STATUS_ERROR: '根据ServiceCode，或者服务状态失败',

  VISIT_OPT_INTERFACE_ERROR: '访问运维接口异常',

  GET_SERVICE_LIST: '获取运维服务资源失败',
  DONOT_HAVE_EXPORT_TEMPLATE: '没有符合导出的模板',
  UPLOAD_FILE_ERROR: '上传文件失败',
  STOP_HEOS_POD_ERROR: '停止该项目部署发布的服务失败',

  IS_NOT_STRING: function (x) {
    return `${x}不是字符串`;
  },

  IS_NOT_NUMBER: function (x) {
    return `${x}不是数字`;
  },

  IS_NOT_INT: function (x) {
    return `${x}不是整数`;
  },

  IS_NOT_CORRECT_PORT: function (x) {
    return `${x}不是合法的端口号`;
  },

  IS_NOT_IN: function (x, allowed) {
    return `${x}不属于允许的值范围，允许的值为:${allowed}`;
  },

  IS_NOT_BOOLEAN: function (x) {
    return `${x}不是布尔值`;
  },

  IS_EMPTY: function (x) {
    return `${x}为空`;
  },
  OVER_MAX_CHAR: function (field, maxLength) {
    return `${field}最大${maxLength}个字符`;
  },
  NOT_MATCH_NAME_RULE: function (field) {
    return `${field}不合法规则,只能包含大小写字母、数字、中文、下划线、中划线、#`;
  },
  NOT_MATCH_ID_RULE: function (field) {
    return `${field}不存在或格式错误`;
  },
  OVER_MAX_INSERT_MANY_COUNT: function (limit) {
    return `数据量过大，超过${limit}条限制`;
  },
  NOT_MATCH_NODE_IP_RULE: function (field, ip) {
    return `${field}服务，节点选择${ip}错误，此节点不可用`;
  },
  NOT_MATCH_FEPNODE_IP_RULE: function (field, ip, type) {
    return `${field}服务，节点选择${ip}错误, 此节点已经部署${type}，请选择其他节点部署安装`;
  },
  NOT_MATCH_FEPNODE_IP_RULE_Ex: function (field, ip, field2) {
    return `${field}服务与${field2}服务, 节点都选择${ip}错误, 请选择其他节点`;
  },
  NOT_MATCH_PROCESS_RULE: function (field) {
    return `${field}服务，更多配置错误`;
  },
  NOT_CONFIG_NODE_IP_RULE: function (field) {
    return `${field}服务，节点选择错误`;
  },
  NOT_MATCH_MODELING_FOLDER_RULE: function (field) {
    return `${field}服务，实时服务未选择`;
  },
  NOT_MATCH_PROCESS_PACKAGE_VERSION_RULE: function (server, field, version) {
    return `${server}服务，${field}进程，待更新版本选择${version}错误`;
  },
  NOT_MATCH_PROCESS_CPU_CORE_RULE: function (
    server,
    field,
    cpuCore,
    limitCpuCore,
  ) {
    return `${server}服务，${field}进程，cpu(核)选择错误, cpu(核) >= ${limitCpuCore}`;
  },

  NOT_MATCH_PROCESS_MEMORY_SIZE_RULE: function (
    server,
    field,
    memorySize,
    limitMemorySize,
  ) {
    return `${server}服务，${field}进程，内存选择错误, 内存 >= ${limitMemorySize}`;
  },

  NOT_MATCH_DEPLOY_CPU_RESOURCE_ERROR: function (
    server,
    needCpu,
    availableCpu,
  ) {
    return `${server}节点 CPU资源不足, 需要CPU资源为${needCpu}, 可用的CPU资源为${availableCpu}, 部署安装失败`;
  },
  NOT_MATCH_DEPLOY_MEMORY_RESOURCE_ERROR: function (
    server,
    needMemory,
    availableMemory,
  ) {
    return `${server}节点 内存资源不足, 需要内存资源为 ${needMemory}, 可用的内存资源为${availableMemory}, 部署安装失败`;
  },

  NOT_MATCH_DEVELOPMENT_STANDALONE_RULE: function (server) {
    return `${server}服务，部署方式选择错误：只支持单例部署`;
  },

  NOT_MATCH_GATEWAY_PROCESS_RULE: function (server) {
    return `${server}服务，未创建通道，请创建通道后，再发布数据`;
  },
  NOT_MATCH_NAME_UNIQUE_RULE: function (name) {
    return `名称 ${name} 重复`;
  },

  TEST_CONNECT_IP_FAILED: function (ip) {
    return `${ip} 链接超时`;
  },
  CHECK_DELETE_NODE_FAILED: function (ip) {
    return `测试删除节点 ${ip} 失败`;
  },
  GET_NODES_INFO_FAILED: function (ips) {
    return `获取节点 ${ips} 失败`;
  },
  NOT_MATCH_IMPORT_NAME_RULE: function (field) {
    return `导入失败，模型名称${field}重复`;
  },
  NOT_MATCH_IMPORT_INDUSTRY_NAME_RULE: function (field) {
    return `导入失败，标签名称${field}重复`;
  },
  NOT_MATCH_FILE_IMPORT_EXPORT_RULE: function (dir) {
    return `导入/导出目录${dir}创建失败`;
  },
  NOT_MATCH_FILE_IMPORT_RULE: function (file) {
    return `导入文件包缺少${file}文件`;
  },
  NOT_MATCH_FILE_IMPORT_RULE_EX: function (file) {
    return `导入文件包${file}文件内容错误`;
  },
  NOT_MATCH_COMMAND_RULE: function (cmd) {
    return `执行命令${cmd}失败`;
  },
  NOT_MATCH_FILE_EXPORT_RULE: function (file) {
    return `导出${file}文件不存在`;
  },
  NOT_MATCH_VAR_ELEMENT_RULE: function (field, maxCount) {
    return `${field}服务，变量个数已超上限值${maxCount}`;
  },
  NOT_MATCH_LOGIC_ELEMENT_RULE: function (field, maxCount) {
    return `${field}服务，逻辑个数已超上限值${maxCount}`;
  },
  NOT_MATCH_SERVICE_ELEMENT_RULE: function (field, maxCount) {
    return `${field}服务，方法个数已超上限值${maxCount}`;
  },
  NOT_MATCH_EVENT_ELEMENT_RULE: function (field, maxCount) {
    return `${field}服务，事件个数已超上限值${maxCount}`;
  },
  NOT_MATCH_ALARM_ELEMENT_RULE: function (field, maxCount) {
    return `${field}服务，告警个数已超上限值${maxCount}`;
  },
};
